export class AjaxResult {
  code: number;
  message: string;
  data: any;

  constructor(code: number, message: string, data: any = null) {
    this.code = code;
    this.message = message;
    this.data = data;
  }

  static success(data: any = null, message: string = '操作成功'): AjaxResult {
    return new AjaxResult(200, message, data);
  }

  static error(message: string = '操作失败', code: number = 500): AjaxResult {
    return new AjaxResult(code, message);
  }

  static unauthorized(message: string = '未授权'): AjaxResult {
    return new AjaxResult(401, message);
  }

  static forbidden(message: string = '禁止访问'): AjaxResult {
    return new AjaxResult(403, message);
  }

  static notFound(message: string = '资源不存在'): AjaxResult {
    return new AjaxResult(404, message);
  }

  static badRequest(message: string = '请求参数错误'): AjaxResult {
    return new AjaxResult(400, message);
  }
} 